/**
 * 
 */
package com.yidu.erp.service.sell;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mysql.fabric.xmlrpc.base.Data;
import com.yidu.erp.dao.BeyondMoneyMapper;
import com.yidu.erp.model.BeyondMoney;
import com.yidu.erp.model.BeyondPlanmx;
import com.yidu.erp.model.BeyondSalplan;
import com.yidu.erp.model.BeyondWare;

/**
 * 财务图形实现类
 * @author WangGuanfu
 *
 */
@Service
public class BeyondMoneyServiceImpl implements BeyondMoneyService{

	@Resource
	private  BeyondMoneyMapper beyondMoneyMapper;

	@Override
	public List<BeyondMoney> selectMoneyByOptime(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return beyondMoneyMapper.selectMoneyByOptime(map);
	}

	@Override
	public List<BeyondMoney> selectMoneyByAnnexId(Map<String, Object> parMap) {
		//传入年份得到资金申请集合
		List<BeyondMoney> applyassetlist = beyondMoneyMapper.selectMoneyByAnnexId(parMap);
		//定义一个ArrayList集合
		List<BeyondMoney> list = new ArrayList<BeyondMoney>();
		//循环12月 用于判断取出的资金申请有无该月份
		for(int i=1;i<=12;i++){
			//定义一个财务支出实体类
			BeyondMoney app = new BeyondMoney();
			//循环遍历资金申请集合
			for (Iterator iterator = applyassetlist.iterator(); iterator.hasNext();) {
				//根据循环的索引得到资金申请类
				BeyondMoney erpApplyasset = (BeyondMoney) iterator.next();
				//循环的次数小于10次进行下列方法
				if(i<10){
					//资金申请时间等于0+循环的次数进行下列方法
					if(erpApplyasset.getVarOptime().equals("0"+i)){
						//将定义的资金申请时间赋值为遍历取到的资金申请时间
						app.setOptime(erpApplyasset.getOptime());
						//将定义的资金申请金额赋值为遍历取到的资金申请金额
						app.setMoneySummoney(app.getMoneySummoney());
						//跳过当前循环
						break;
					}else{
						//将定义的资金申请时间赋值为0+循环的次数
						Date date = new Date();
						app.setOptime(date);
						//将定义的资金申请金额赋值为0
						app.setMoneySummoney(0.0);
					}
				}else{
					//资金申请时间等于循环的次数进行下列方法
					if(erpApplyasset.getVarOptime().equals(""+i)){
						//将定义的资金申请时间赋值为遍历取到的资金申请时间
						app.setOptime(erpApplyasset.getOptime());
						//将定义的资金申请金额赋值为遍历取到的资金申请金额
						app.setMoneySummoney(erpApplyasset.getMoneySummoney());	
						//跳过当前循环
						break;
					}else{
						//将定义的资金申请时间赋值为0+循环的次数
						Date date = new Date();
						app.setOptime(date);
						//将定义的资金申请金额赋值为0
						app.setMoneySummoney(0.0);
					}
				}
			}
			//将list增加定义的资金申请对象
			list.add(app);
		}
		//返回list集合
		return list;
	}

	@Override
	public List<BeyondSalplan> selectware(Map<String,Object>map) {
		// TODO Auto-generated method stub
		return beyondMoneyMapper.selectware(map);
	}

	@Override
	public double selectMoneyBystaffId() {
		// TODO Auto-generated method stub
		return beyondMoneyMapper.selectMoneyBystaffId();
	}

	@Override
	public int selectStaffNum() {
		// TODO Auto-generated method stub
		return beyondMoneyMapper.selectStaffNum();
	}

	@Override
	public int selectSctockmpNum() {
		// TODO Auto-generated method stub
		return beyondMoneyMapper.selectSctockmpNum();
	}

	@Override
	public int selectDate(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return beyondMoneyMapper.selectDate(map);
	}

	@Override
	public double selectMoneySum() {
		// TODO Auto-generated method stub
		return beyondMoneyMapper.selectMoneySum();
	}

	@Override
	public List<BeyondSalplan> selectZongSale(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return beyondMoneyMapper.selectZongSale(map);
	}
	
}
